<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateCmsFieldTypesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('cms_field_types')) {
            Schema::create('cms_field_types', function (Blueprint $table) {
                $table->id();
                $table->string('type')->comment('控件类型');
                $table->string('label')->comment('控件名称');
                $table->json('meta')->nullable()->comment('控件元');
                $table->enum('status', ['normal', 'ban'])->default('normal')->comment('控件可用状态');
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `cms_field_types` comment 'CMS字段支持类型'");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cms_field_types');
    }
}
